package week2;

import org.junit.Test;

import java.util.Scanner;

public class CSTest2 {
    public void isHui(){
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        char[] array = str.toCharArray();
        boolean bool = true;
        for (int i = 0; i < (array.length - 1) / 2; i++){
             if(array[i] != array[array.length - 1 -i]){
                 bool = false;
                 break;
            }
        }
        System.out.println(bool ? "是回文" : "不是回文");
    }

    @Test
    public void bubbleSort(){
        int[] array = {1,5,9,4,8,6,4,1,9,7};
        for (int i = 0; i < array.length - 1; i++ ){
            for (int j = 1; j < array.length - i; j++){
                if(array[j - 1] == array[j]){
                    array[j - 1] = array[j - 1];
                    array[j] = array[j];
                }
                int max = array[j - 1] > array[j] ? array[j - 1] : array[j];
                int min = array[j - 1] < array[j] ? array[j - 1] : array[j];
                array[j] = max;
                array[j - 1] = min;
            }
        }
        for (int k = 0; k < array.length; k++) {
            System.out.println(array[k]);
        }
    }



}
